<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 25] 25.32 java.lang.Integer (JDK 1.0)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:27:06 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_31.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 25<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch25_33.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-32">25.32 java.lang.Integer (JDK 1.0)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-32.1"></A></h3>
</DIV>

<P CLASS=para>
This class provides an immutable object wrapper around the
<tt CLASS=literal>int</tt> primitive data type.  This
class also contains useful minimum and maximum
constants and useful conversion methods.
<tt CLASS=literal>parseInt()</tt> and <tt CLASS=literal>valueOf()</tt> convert a string
to an <tt CLASS=literal>int</tt> or to an <tt CLASS=literal>Integer</tt>,
respectively. Each can take a radix argument to
specify the base that the value is represented in.
<tt CLASS=literal>decode()</tt> also converts a <tt CLASS=literal>String</tt> to an
<tt CLASS=literal>Integer</tt>.  It assumes a hexadecimal number if the
string begins with "0X" or "0x," or an octal
number if the string begins with "0". Otherwise, a decimal number is assumed.

<P CLASS=para>
<tt CLASS=literal>toString()</tt> converts in the other direction, and the
<tt CLASS=literal>static</tt> version takes a radix
argument. <tt CLASS=literal>toBinaryString()</tt>, <tt CLASS=literal>toOctalString()</tt>,
and <tt CLASS=literal>toHexString()</tt> convert an <tt CLASS=literal>int</tt> to a string
using base 2, base 8, and base 16.  These methods treat the
integer as an unsigned value.

<P CLASS=para>
Other routines return the value of an <tt CLASS=literal>Integer</tt> as
various primitive types, and finally, the
<tt CLASS=literal>getInteger()</tt> methods
return the integer value of a named property from the system
property list or the specified default value.

<DIV CLASS=screen>
<P>
<PRE>
public final class <tt CLASS=literal>Integer</tt> extends Number {
    // <tt CLASS=literal>Public Constructors</tt>
            public <tt CLASS=literal>Integer</tt>(int <tt CLASS=literal>value</tt>);
            public <tt CLASS=literal>Integer</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
    // <tt CLASS=literal>Constants</tt>
            public static final int <tt CLASS=literal>MAX_VALUE</tt>;
            public static final int <tt CLASS=literal>MIN_VALUE</tt>;
        <b>1.1</b>public static final Class <tt CLASS=literal>TYPE</tt>;
    // <tt CLASS=literal>Class Methods</tt>
        <b>1.1</b>public static Integer <tt CLASS=literal>decode</tt>(String <tt CLASS=literal>nm</tt>) throws NumberFormatException;
            public static Integer <tt CLASS=literal>getInteger</tt>(String <tt CLASS=literal>nm</tt>);
            public static Integer <tt CLASS=literal>getInteger</tt>(String <tt CLASS=literal>nm</tt>, int <tt CLASS=literal>val</tt>);
            public static Integer <tt CLASS=literal>getInteger</tt>(String <tt CLASS=literal>nm</tt>, Integer <tt CLASS=literal>val</tt>);
            public static int <tt CLASS=literal>parseInt</tt>(String <tt CLASS=literal>s</tt>, int <tt CLASS=literal>radix</tt>) throws NumberFormatException;
            public static int <tt CLASS=literal>parseInt</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
            public static String <tt CLASS=literal>toBinaryString</tt>(int <tt CLASS=literal>i</tt>);
            public static String <tt CLASS=literal>toHexString</tt>(int <tt CLASS=literal>i</tt>);
            public static String <tt CLASS=literal>toOctalString</tt>(int <tt CLASS=literal>i</tt>);
            public static String <tt CLASS=literal>toString</tt>(int <tt CLASS=literal>i</tt>, int <tt CLASS=literal>radix</tt>);
            public static String <tt CLASS=literal>toString</tt>(int <tt CLASS=literal>i</tt>);
            public static Integer <tt CLASS=literal>valueOf</tt>(String <tt CLASS=literal>s</tt>, int <tt CLASS=literal>radix</tt>) throws NumberFormatException;
            public static Integer <tt CLASS=literal>valueOf</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
    // <tt CLASS=literal>Public Instance Methods</tt>
        <b>1.1</b>public byte <tt CLASS=literal>byteValue</tt>();  //<tt CLASS=literal> Overrides Number</tt>
            public double <tt CLASS=literal>doubleValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public boolean <tt CLASS=literal>equals</tt>(Object <tt CLASS=literal>obj</tt>);  //<tt CLASS=literal> Overrides Object</tt>
            public float <tt CLASS=literal>floatValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public int <tt CLASS=literal>hashCode</tt>();  //<tt CLASS=literal> Overrides Object</tt>
            public int <tt CLASS=literal>intValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public long <tt CLASS=literal>longValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
        <b>1.1</b>public short <tt CLASS=literal>shortValue</tt>();  //<tt CLASS=literal> Overrides Number</tt>
            public String <tt CLASS=literal>toString</tt>();  //<tt CLASS=literal> Overrides Object</tt>
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-32.2">Hierarchy:</A></h3>

<P CLASS=para>
Object->Number(Serializable)->Integer

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-32.3">Passed To:</A></h3>

<P CLASS=para>
Integer.getInteger()

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-32.4">Returned By:</A></h3>

<P CLASS=para>
Integer.decode(), 
Integer.getInteger(), 
Integer.valueOf()

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_31.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch25_33.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.lang.InstantiationException (JDK 1.0)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.lang.InternalError (JDK 1.0)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
